package com.hyh.util;

import android.content.Context;
import android.view.Gravity;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

public class FloatWindowUtil {

    public static void show(Context context){
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
        params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
        params.flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
        params.gravity = Gravity.LEFT | Gravity.TOP;
        params.x = 10;
        params.y = 10;
        params.width = 100;
        params.height = 100;
        TextView textView = new TextView(context);
        textView.setText("123456");
        textView.setLayoutParams(new ViewGroup.LayoutParams(100,100));
        windowManager.addView(textView,params);
    }
}
